package com.eorchis.module.newsuserlink.domain;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import com.eorchis.core.basedao.entity.impl.AbstractBaseEntity;


import org.hibernate.annotations.GenericGenerator;

import com.eorchis.core.basedao.entity.IBaseEntity;
import com.eorchis.module.news.domain.News;
import com.eorchis.module.reply.domain.Reply;

/**
 * Title: NewsUserLink<br>
 * Description: 消息用户关联表实体对象<br>
 * Company: GoldGov<br>
 * Copyright @ 2012 GoldGov .All rights reserved.<br>
 * @author RongSL
 * @createDate 2016-05-06
 * @version $Revision$
 */
@Entity
@Table(name = "NEWS_USER_LINK")
public class NewsUserLink extends AbstractBaseEntity implements IBaseEntity {
	private static final long serialVersionUID = 1L;

	private String newsUserId;//消息管理用户ID
	private Integer readState;//读取状态          1:已读取   2：未读取
	private Integer replyState;//回复状态       1：已回复  2：未回复
	private Integer receiveLookState;//显示状态       1：显示   2：不显示
	private News news;//消息表
	private String userId;//消息接收人
	private Date receiveTime;//接收时间
	private Set<Reply> reply=new HashSet<Reply>();//消息回复

	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	@Column(name="NEWS_USER_ID")
	/**
	 * 设置消息管理用户ID
	 */		
	public String getNewsUserId() {
		return newsUserId;
	}
	/**
	 * 获取消息管理用户ID
	 */		
	public void setNewsUserId(String newsUserId) {
		this.newsUserId = newsUserId;
	}
	@Column(name="READ_STATE")
	/**
	 * 设置读取状态
	 */		
	public Integer getReadState() {
		return readState;
	}
	/**
	 * 获取读取状态
	 */		
	public void setReadState(Integer readState) {
		this.readState = readState;
	}
	@Column(name="REPLY_STATE")
	/**
	 * 设置回复状态
	 */		
	public Integer getReplyState() {
		return replyState;
	}
	/**
	 * 获取回复状态
	 */		
	public void setReplyState(Integer replyState) {
		this.replyState = replyState;
	}
	@Column(name="RECEIVE_LOOK_STATE")
	/**
	 * 设置显示状态
	 */		
	public Integer getReceiveLookState() {
		return receiveLookState;
	}
	/**
	 * 获取显示状态
	 */		
	public void setReceiveLookState(Integer receiveLookState) {
		this.receiveLookState = receiveLookState;
	}
	
	@OneToMany(mappedBy = "newsUserLink", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	public Set<Reply> getReply() {
		return reply;
	}
	public void setReply(Set<Reply> reply) {
		this.reply = reply;
	}

	/**
	 * 记录日志使用
	 */
	public String toString() {
		return "消息管理用户ID======>" + getNewsUserId()+"\n读取状态======>" + getReadState()+"\n回复状态======>" + getReplyState()+"\n显示状态======>" + getReceiveLookState()+"\n消息回复======>" + getReply();
	}

	@ManyToOne(targetEntity=News.class,cascade = CascadeType.ALL, optional = true)
	@JoinColumn(name="NEWS_ID", referencedColumnName="NEWS_ID")
	public News getNews() {
		return news;
	}
	public void setNews(News news) {
		this.news = news;
	}
	
	@Column(name="USER_ID")
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	
	@Column(name="RECEIVE_TIME")
	public Date getReceiveTime() {
		return receiveTime;
	}
	public void setReceiveTime(Date receiveTime) {
		this.receiveTime = receiveTime;
	}
}
